package com.zzyl.mapper;

import com.zzyl.dto.NursingProjectPlanDto;
import com.zzyl.entity.NursingPlan;
import com.zzyl.entity.NursingProjectPlan;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NursingProjectPlanMapper {

    /**
     * 根据护理项目id查询护理项目绑到计划的个数
     * @param projectId
     * @return
     */
    @Select("SELECT COUNT(*)  FROM nursing_project_plan WHERE project_id = #{projectId} GROUP BY project_id;")
    Integer countByProjectId(Long projectId);


    /**
     * 根据护理计划删除关联关系
     * @param nursingPrijectPlanId
     */
    @Delete("DELETE FROM nursing_project_plan WHERE plan_id=#{nursingPrijectPlanId}")
    void deleteByIdNpp(@Param("nursingPrijectPlanId") Long nursingPrijectPlanId);

    /**
     * 删除护理计划之前判断是否正在被调用
     * @param id
     * @return
     */
    @Select("SELECT count(*) FROM nursing_project_plan WHERE plan_id = #{id}")
    int findIdJob(Long id);

    /**
     * 批量添加护理计划和护理项目的关系
     * @param projectPlans
     */
    void saveBatch(List<NursingProjectPlan> projectPlans);


}
